import React from 'react'

var Form = ReactUI.Form
var FormControl = ReactUI.FormControl
var Icon = ReactUI.Icon
var Input = ReactUI.Input
var DatepickerPair = ReactUI.DatepickerPair
var Refetch = ReactUI.Refetch
var Modal = ReactUI.Modal
var FormSubmit = ReactUI.FormSubmit
var Button = ReactUI.Button
export default class UserManager extends React.Component {
    constructor() {
        super();
        this.state = {
            formData:null,
        }
    }
    handleSubmit1(formData){

        var dataHeader='{"header":{"business":"updateUser","destSystem":"SOAPlat","sourceSystem":"SOAPlat","rootParam":"User"},';
        var dataBody='"body":'+JSON.stringify(formData);
        var data = dataHeader+dataBody+"}";
        $.ajax({
            type: 'POST',
            url:'user/add',
            data: "data="+data,
            dataType:'json',
            success: function(result){
                Modal.alert(result);
            },
            error:function(e){
                Modal.alert("操作出错!");

            }
        })

    }
    render() {
        var id = this.props.params.id;
        var dataHeader='{"header":{"business":"getUserById","destSystem":"SOAPlat","sourceSystem":"SOAPlat","rootParam":"User"},';
        var dataBody='"body":'+'{"id":'+id+'}';
        var data = dataHeader+dataBody+"}";
        return (
            <div>
                <div className="bg-light lter b-b wrapper-md">
                    <h1 className="m-n font-thin h3">修改用户</h1>
                </div>
                <div className="wrapper-md">
                <Form onSubmit={this.handleSubmit1} fetch={{
                                                                                    method: 'post',
                                                                                    url: 'user/add?data='+data,
                                                                                    then: (res) => {

                                                                                        return JSON.parse(res);
                                                                                    }
                                                                                }}>
                    <FormControl name="id"

                                 type="hidden"

                                 />
                    <FormControl name="username"
                                 label="用户名"
                                 type="text"
                                 required
                                 grid={{width:12/24}}
                                 min={2}
                                 max={6} />
                    <FormControl grid={{width:12/24}}
                                 name="password"
                                 min={6}
                                 max={20}
                                 required
                                 label="密码"
                                 type="password" />
                    <FormControl grid={{width:12/24}}
                                 name="officePhone"
                                 min={6}
                                 max={20}
                                 label="联系电话"
                                 type="text" />
                    <FormControl name="email" label="邮箱" type="email" grid={{width:12/24}}/>

                    <FormSubmit>
                        <span>提交</span>
                        <Button>Button</Button>
                    </FormSubmit>

                </Form>
                </div>
            </div>

        )
    }
}